package cn.dliyy.aop;

import org.aspectj.bridge.AbortException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

@Aspect
public class DaoAop {
	public Object retVal;
	@Pointcut("execution(* cn.dliyy.warehouse.dao.EntityDao.*(..)) && target(cn.dliyy.warehouse.dao.EntityDao)")
	public void pointcut() {
	}
	@Around("pointcut()")
	public Object AroundAdivse(ProceedingJoinPoint pjp) throws Throwable {
		try {
			retVal = pjp.proceed();
		} catch (HibernateOptimisticLockingFailureException ex) {
			System.out.println("-----------HibernateOptimisticLockingFailureException"+ex);
			// showMessage(ex,
			// SharedMessages.error.getMessage("error.com.0087"));
			// throw new AbortProcessingException(ex);
		} catch (DataAccessResourceFailureException ex) {
			System.out.println("-----------DataAccessResourceFailureException"+ex);
			// showMessage(ex,
			// SharedMessages.other.getMessage("error.database.connection"));
			// throw new AbortProcessingException(ex);
		} catch (AbortException ex) {
			System.out.println("-----------AbortException"+ex);
			// showMessage(ex, null);
			throw ex;
		} catch (Exception ex) {
			System.out.println("-----------Exception"+ex);
			// showMessage(ex, SharedMessages.other.getMessage("error.other"));
			// throw new AbortProcessingException(ex);
		}
		return retVal;
	}
}
